*     *****************************************************************   *;
*     *****************************************************************   *; 
*   Date:          December 27, 2021                               	      *;
*   Authors:       Lisa Dellmuth and Jonas Tallberg				          *;   
*   Purpose: 	   Analyses for book Legitimacy Politics: Elite  		  *;
*    Communication and Public Opinion in Global Governance (CUP, 2023)    *;
*     ****************************************************************    *;
*     ****************************************************************    *;


set more off

use Elitecom.dta, clear

*     ***************************************************************** *;
*   File-Name:  Figures 4.5-4.7.do                                      *;  
*     ****************************************************************  *;


*First, retrieve estimates

*UN

preserve
reg conf t_in_p if io==1 [aw=weight], cluster(id) 
parmest, label norestore escal(N) saving(inp_un.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
*non–integer degrees of freedom for unequal–variance t–tests 
*(Satterthwaite, 1946)[5], which metaparm uses as the default
restore

preserve
reg conf t_in_n if io==1 [aw=weight], cluster(id) 
parmest, label norestore escal(N) saving(inn_un.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore

preserve
reg conf t_out_p if io==1 [aw=weight], cluster(id) 
parmest, label norestore escal(N) saving(outp_un.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore

preserve
reg conf t_out_n if io==1 [aw=weight], cluster(id)   
parmest, label norestore escal(N) saving(outn_un.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore

***
preserve
reg conf t_cso_p if io==1 [aw=weight], cluster(id) 
parmest, label norestore escal(N) saving(csop_un.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore

preserve
reg conf t_cso_n if io==1 [aw=weight], cluster(id)  
parmest, label norestore escal(N) saving(cson_un.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore

preserve
reg conf t_io_p if io==1 [aw=weight], cluster(id)  
parmest, label norestore escal(N) saving(iop_un.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore

preserve
reg conf t_io_n if io==1 [aw=weight], cluster(id)  
parmest, label norestore escal(N) saving(ion_un.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore

preserve
reg conf t_gov_p if io==1 [aw=weight], cluster(id)  
parmest, label norestore escal(N) saving(govp_un.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore

preserve
reg conf t_gov_n if io==1 [aw=weight], cluster(id)  
parmest, label norestore escal(N) saving(govn_un.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore


***

preserve
reg conf t_p if io==1 [aw=weight], cluster(id) 
parmest, label norestore escal(N) saving(pos_un.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore

preserve
reg conf t_n if io==1 [aw=weight], cluster(id)  
parmest, label norestore escal(N) saving(neg_un.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore 



*IMF

preserve
reg conf t_in_p if io==4 [aw=weight], cluster(id)  
parmest, label norestore escal(N) saving(inp_imf.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore

preserve
reg conf t_in_n if io==4 [aw=weight], cluster(id)  
parmest, label norestore escal(N) saving(inn_imf.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore

preserve
reg conf t_out_p if io==4 [aw=weight], cluster(id) 
parmest, label norestore escal(N) saving(outp_imf.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore

preserve
reg conf t_out_n if io==4 [aw=weight], cluster(id) 
parmest, label norestore escal(N) saving(outn_imf.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore 

***
preserve
reg conf t_cso_p if io==4 [aw=weight], cluster(id)  
parmest, label norestore escal(N) saving(csop_imf.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore

preserve
reg conf t_cso_n if io==4 [aw=weight], cluster(id)  
parmest, label norestore escal(N) saving(cson_imf.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore

preserve
reg conf t_io_p if io==4 [aw=weight], cluster(id)  
parmest, label norestore escal(N) saving(iop_imf.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore

preserve
reg conf t_io_n if io==4 [aw=weight], cluster(id)  
parmest, label norestore escal(N) saving(ion_imf.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore

preserve
reg conf t_gov_p if io==4 [aw=weight], cluster(id) 
parmest, label norestore escal(N) saving(govp_imf.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore

preserve
reg conf t_gov_n if io==4 [aw=weight], cluster(id) 
parmest, label norestore escal(N) saving(govn_imf.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore
 

***

preserve
reg conf t_p if io==4 [aw=weight], cluster(id) 
parmest, label norestore escal(N) saving(pos_imf.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore

preserve
reg conf t_n if io==4 [aw=weight], cluster(id) 
parmest, label norestore escal(N) saving(neg_imf.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore




*WTO
preserve
reg conf t_in_p if io==5 [aw=weight], cluster(id) 
parmest, label norestore escal(N) saving(inp_wto.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore

preserve
reg conf t_in_n if io==5 [aw=weight], cluster(id) 
parmest, label norestore escal(N) saving(inn_wto.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore

preserve
reg conf t_out_p if io==5 [aw=weight], cluster(id) 
parmest, label norestore escal(N) saving(outp_wto.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore

preserve
reg conf t_out_n if io==5 [aw=weight], cluster(id) 
parmest, label norestore escal(N) saving(outn_wto.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore
 
***
preserve
reg conf t_cso_p if io==5 [aw=weight], cluster(id) 
parmest, label norestore escal(N) saving(csop_wto.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore

preserve
reg conf t_cso_n if io==5 [aw=weight], cluster(id) 
parmest, label norestore escal(N) saving(cson_wto.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore

preserve
reg conf t_io_p if io==5 [aw=weight], cluster(id)  
parmest, label norestore escal(N) saving(iop_wto.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore

preserve
reg conf t_io_n if io==5 [aw=weight], cluster(id)  
parmest, label norestore escal(N) saving(ion_wto.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore

preserve
reg conf t_gov_p if io==5 [aw=weight], cluster(id)  
parmest, label norestore escal(N) saving(govp_wto.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore

preserve
reg conf t_gov_n if io==5 [aw=weight], cluster(id) 
parmest, label norestore escal(N) saving(govn_wto.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore

***
preserve
reg conf t_p if io==5 [aw=weight], cluster(id) 
parmest, label norestore escal(N) saving(pos_wto.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore

preserve
reg conf t_n if io==5 [aw=weight], cluster(id)   
parmest, label norestore escal(N) saving(neg_wto.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore


*EU

preserve
reg conf t_in_p if io==2 [aw=weight], cluster(id) 
parmest, label norestore escal(N) saving(inp_eu.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore

preserve
reg conf t_in_n if io==2 [aw=weight], cluster(id)  
parmest, label norestore escal(N) saving(inn_eu.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore

preserve
reg conf t_out_p if io==2 [aw=weight], cluster(id) 
parmest, label norestore escal(N) saving(outp_eu.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore

preserve
reg conf t_out_n if io==2 [aw=weight], cluster(id) 
parmest, label norestore escal(N) saving(outn_eu.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore
 
***

preserve
reg conf t_cso_p if io==2 [aw=weight], cluster(id) 
parmest, label norestore escal(N) saving(csop_eu.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore

preserve
reg conf t_cso_n if io==2 [aw=weight], cluster(id) 
parmest, label norestore escal(N) saving(cson_eu.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore

preserve
reg conf t_io_p if io==2 [aw=weight], cluster(id) 
parmest, label norestore escal(N) saving(iop_eu.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore

preserve
reg conf t_io_n if io==2 [aw=weight], cluster(id) 
parmest, label norestore escal(N) saving(ion_eu.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore

preserve
reg conf t_gov_p if io==2 [aw=weight], cluster(id) 
parmest, label norestore escal(N) saving(govp_eu.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore

preserve
reg conf t_gov_n if io==2 [aw=weight], cluster(id) 
parmest, label norestore escal(N) saving(govn_eu.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore 


***
preserve
reg conf t_p if io==2 [aw=weight], cluster(id) 
parmest, label norestore escal(N) saving(pos_eu.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore

preserve
reg conf t_n if io==2 [aw=weight], cluster(id) 
parmest, label norestore escal(N) saving(neg_eu.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore 


*NAFTA

preserve
reg conf t_in_p if io==3 [aw=weight], cluster(id) 
parmest, label norestore escal(N) saving(inp_nafta.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore

preserve
reg conf t_in_n if io==3 [aw=weight], cluster(id) 
parmest, label norestore escal(N) saving(inn_nafta.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore

preserve
reg conf t_out_p if io==3 [aw=weight], cluster(id) 
parmest, label norestore escal(N) saving(outp_nafta.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore

preserve
reg conf t_out_n if io==3 [aw=weight], cluster(id) 
parmest, label norestore escal(N) saving(outn_nafta.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore 

***
preserve
reg conf t_cso_p if io==3 [aw=weight], cluster(id) 
parmest, label norestore escal(N) saving(csop_nafta.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore

preserve
reg conf t_cso_n if io==3 [aw=weight], cluster(id) 
parmest, label norestore escal(N) saving(cson_nafta.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore

preserve
reg conf t_io_p if io==3 [aw=weight], cluster(id) 
parmest, label norestore escal(N) saving(iop_nafta.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore

preserve
reg conf t_io_n if io==3 [aw=weight], cluster(id) 
parmest, label norestore escal(N) saving(ion_nafta.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore

preserve
reg conf t_gov_p if io==3 [aw=weight], cluster(id) 
parmest, label norestore escal(N) saving(govp_nafta.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore

preserve
reg conf t_gov_n if io==3 [aw=weight], cluster(id) 
parmest, label norestore escal(N) saving(govn_nafta.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore

***
preserve
reg conf t_p if io==3 [aw=weight], cluster(id) 
parmest, label norestore escal(N) saving(pos_nafta.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore

preserve
reg conf t_n if io==3 [aw=weight], cluster(id)  
parmest, label norestore escal(N) saving(neg_nafta.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs
restore


*Second, merge data sets for figures 

 
use inp_un.dta, clear
merge 1:1 parm using inn_un.dta
drop _merge
merge 1:1 parm using outp_un.dta
drop _merge
merge 1:1 parm using outn_un.dta
drop _merge
merge 1:1 parm using csop_un.dta
drop _merge
merge 1:1 parm using cson_un.dta
drop _merge
merge 1:1 parm using iop_un.dta
drop _merge
merge 1:1 parm using ion_un.dta
drop _merge
merge 1:1 parm using govp_un.dta
drop _merge
merge 1:1 parm using govn_un.dta 
drop _merge
merge 1:1 parm using pos_un.dta
drop _merge
merge 1:1 parm using neg_un.dta 
drop _merge
saveold un.dta, replace

use inp_imf.dta, clear
merge 1:1 parm using inn_imf.dta
drop _merge
merge 1:1 parm using outp_imf.dta
drop _merge
merge 1:1 parm using outn_imf.dta
drop _merge
merge 1:1 parm using csop_imf.dta
drop _merge
merge 1:1 parm using cson_imf.dta
drop _merge
merge 1:1 parm using iop_imf.dta
drop _merge
merge 1:1 parm using ion_imf.dta
drop _merge
merge 1:1 parm using govp_imf.dta
drop _merge
merge 1:1 parm using govn_imf.dta 
drop _merge
merge 1:1 parm using pos_imf.dta
drop _merge
merge 1:1 parm using neg_imf.dta 
drop _merge
saveold imf.dta, replace

use inp_wto.dta, clear
merge 1:1 parm using inn_wto.dta
drop _merge
merge 1:1 parm using outp_wto.dta
drop _merge
merge 1:1 parm using outn_wto.dta
drop _merge
merge 1:1 parm using csop_wto.dta
drop _merge
merge 1:1 parm using cson_wto.dta
drop _merge
merge 1:1 parm using iop_wto.dta
drop _merge
merge 1:1 parm using ion_wto.dta
drop _merge
merge 1:1 parm using govp_wto.dta
drop _merge
merge 1:1 parm using govn_wto.dta 
drop _merge
merge 1:1 parm using pos_wto.dta
drop _merge
merge 1:1 parm using neg_wto.dta 
drop _merge
saveold wto.dta, replace

use inp_eu.dta, clear
merge 1:1 parm using inn_eu.dta
drop _merge
merge 1:1 parm using outp_eu.dta
drop _merge
merge 1:1 parm using outn_eu.dta
drop _merge
merge 1:1 parm using csop_eu.dta
drop _merge
merge 1:1 parm using cson_eu.dta
drop _merge
merge 1:1 parm using iop_eu.dta
drop _merge
merge 1:1 parm using ion_eu.dta
drop _merge
merge 1:1 parm using govp_eu.dta
drop _merge
merge 1:1 parm using govn_eu.dta 
drop _merge
merge 1:1 parm using pos_eu.dta
drop _merge
merge 1:1 parm using neg_eu.dta 
drop _merge
saveold eu.dta, replace

use inp_nafta.dta, clear
merge 1:1 parm using inn_nafta.dta
drop _merge
merge 1:1 parm using outp_nafta.dta
drop _merge
merge 1:1 parm using outn_nafta.dta
drop _merge
merge 1:1 parm using csop_nafta.dta
drop _merge
merge 1:1 parm using cson_nafta.dta
drop _merge
merge 1:1 parm using iop_nafta.dta
drop _merge
merge 1:1 parm using ion_nafta.dta
drop _merge
merge 1:1 parm using govp_nafta.dta
drop _merge
merge 1:1 parm using govn_nafta.dta 
drop _merge
merge 1:1 parm using pos_nafta.dta
drop _merge
merge 1:1 parm using neg_nafta.dta 
drop _merge
saveold nafta.dta, replace

ed


*Merge data in IO-specific datasets first
****************************************************************
use un.dta, clear
ed
drop in 1
drop label
gen io5=1
save un.dta, replace

use imf.dta, clear
ed
drop in 1
drop label
gen io5=2
save imf.dta, replace

use wto.dta, clear
ed
drop in 1
drop label
gen io5=3
save wto.dta, replace

use eu.dta, clear
ed
drop in 1
drop label
gen io5=4
save eu.dta, replace

use nafta.dta, clear
ed
drop in 1
drop label
gen io5=5
save nafta.dta, replace



*Third, append all files
************************************************
*NAFTA file is open

append using eu.dta
append using imf.dta
append using wto.dta
append using un.dta

*Input-output - figure 5

label define io5 1 "UN" 2 "IMF" 3 "WTO" 4 "EU" 5 "NAFTA"
label values io5 io5
tab io5

gen tg=.
label var tg "Treatment group"
sort tg io5

gen ate=.
gen yl=.
gen yu=.

saveold allIOs.dta, replace

sort parm
ed
replace tg=1 if parm=="t_in_p"
replace tg=2 if parm=="t_in_n"
replace tg=3 if parm=="t_out_p"
replace tg=4 if parm=="t_out_n"

label define tg 1 "Positive-input" 2 "Negative-input" 3 "Positive-output" 4 "Negative-output" 
label values tg tg

drop if tg==.
saveold allIOs-fig5.dta, replace

*Elite types - figure 4

use allIOs.dta, clear
ed
replace tg=1 if parm=="t_cso_p"
replace tg=2 if parm=="t_cso_n"
replace tg=3 if parm=="t_io_p"
replace tg=4 if parm=="t_io_n"
replace tg=5 if parm=="t_gov_p"
replace tg=6 if parm=="t_gov_n"

label define tg 1 "Positive-CSOs" 2 "Negative-CSOs" 3 "Positive-IOs" 4 "Negative-IOs" 5 "Positive-Governments" 6 "Negative-Governments" 
label values tg tg

drop if tg==.
saveold allIOs-fig4.dta, replace

*Valence - figure 6

use allIOs.dta, clear
ed
replace tg=1 if parm=="t_p"
replace tg=2 if parm=="t_n" 

label define tg 1 "Positive" 2 "Negative" 
label values tg tg

drop if tg==.
saveold allIOs-fig6.dta, replace


***Figures will look like this:

/*
		|
		|			io
		|
y=ATE	|
		|
		|
		|
		|
		-------------------
				x=tg
				

				*/
				
				
		
*Fig 4.5
************************************************
use allIOs-fig4.dta, clear

drop yl yu ate
				
rename min95 yl
rename max95 yu
rename estimate ate
			
local varname ate
local group1 tg
local group2 io5

sort `group1' `group2'
gen x = _n
replace x = _n + 2 if _n >= 6
replace x = _n + 4 if _n >= 11
replace x = _n + 6 if _n >= 16
replace x = _n + 8 if _n >= 21
replace x = _n + 10 if _n >= 26

separate ate, by(io5)
separate yu, by(io5)
separate yl, by(io5)

twoway (scatter ate1 x , msymbol(S) msize(medium) mcolor(black)) ///
       (rcap yu1 yl1 x, lcolor(black))  ///
       (scatter ate2 x , msymbol(Oh) msize(large) mcolor(black)) ///
       (rcap yu2 yl2 x, lcolor(black) )  ///
       (scatter ate3 x , msymbol(T) msize(medium) mcolor(black)) ///
       (rcap yu3 yl3 x, lcolor(black) )  ///
       (scatter ate4 x , msymbol(D) msize(medium) mcolor(black)) ///
       (rcap yu4 yl4 x, lcolor(black) )  ///
       (scatter ate5 x , msymbol(X) msize(large) mcolor(black)) ///
       (rcap yu5 yl5 x, lcolor(black) ), scheme(lean1)  ///
	   xlabel(none) xtitle(" ", size(3)) b2("Treatment groups compared to control group") ///
	   ytitle(Average treatment effect, size(3)) yscale(r(-1(.5)1)) ///
	   text(-1.2 1 "CSOs (pos.)", place(e) size(2.5)) ///
	   text(-1.2 7.5 "CSOs (neg.)", place(e) size(2.5)) ///
	   text(-1.2 15 "IOs (pos.)", place(e) size(2.5)) ///
	   text(-1.2 22 "IOs (neg.)", place(e) size(2.5)) ///
	   text(-1.2 26.5 "Governments (pos.)", place(e) size(2.5)) ///
	   text(-1.2 34 "Governments (neg.)", place(e) size(2.5)) ///
	   legend(order(1 "UN" 3 "IMF" 5 "WTO" 7 "EU" 9 "NAFTA") position(1) row(1) ring(0)) ///
	   name(fig4, replace) graphregion(color(white)) ylab(, labsize(2.5) nogrid) ///
	   yline(0, lcolor(black) lpattern(dash))
		   
	   *Adjust x-title manually

saveold allIOs-fig4.dta, replace


*Fig 4.6
************************************************
use allIOs-fig5.dta, clear

drop yl yu ate
				
rename min95 yl
rename max95 yu
rename estimate ate
			
local varname ate
local group1 tg
local group2 io5

sort `group1' `group2'
gen x = _n
replace x = _n + 2 if _n >= 6
replace x = _n + 4 if _n >= 11
replace x = _n + 6 if _n >= 16

separate ate, by(io5)
separate yu, by(io5)
separate yl, by(io5)

twoway (scatter ate1 x , msymbol(S) msize(medium) mcolor(black)) ///
       (rcap yu1 yl1 x, lcolor(black))  ///
       (scatter ate2 x , msymbol(Oh) msize(large) mcolor(black)) ///
       (rcap yu2 yl2 x, lcolor(black) )  ///
       (scatter ate3 x , msymbol(T) msize(medium) mcolor(black)) ///
       (rcap yu3 yl3 x, lcolor(black) )  ///
       (scatter ate4 x , msymbol(D) msize(medium) mcolor(black)) ///
       (rcap yu4 yl4 x, lcolor(black) )  ///
       (scatter ate5 x , msymbol(X) msize(large) mcolor(black)) ///
       (rcap yu5 yl5 x, lcolor(black) ), scheme(lean1)  ///
	   xlabel(none) xtitle(" ", size(3)) b2("Treatment groups compared to control group") ///
	   ytitle(Average treatment effect, size(3)) yscale(r(-.75(2.5).5)) ///
	   text(-1.1 .5 "Procedures (pos.)", place(e) size(2.5)) ///
	   text(-1.1 7 "Procedures (neg.)", place(e) size(2.5)) ///
	   text(-1.1 14 "Performance (pos.)", place(e) size(2.5)) ///
	   text(-1.1 22 "Performance (neg.)", place(e) size(2.5)) ///
	   legend(order(1 "UN" 3 "IMF" 5 "WTO" 7 "EU" 9 "NAFTA") position(1) row(1) ring(0)) ///
	   name(fig5, replace) graphregion(color(white)) ylab(, labsize(2.5) nogrid) ///
	   yline(0, lcolor(black) lpattern(dash))
	   
	   *then manually adjust y-scale to -.75 at the lower boundary

saveold allIOs-fig5.dta, replace


		
				
*Fig 4.7
************************************************
use allIOs-fig6.dta, clear

drop yl yu ate
				
rename min95 yl
rename max95 yu
rename estimate ate
			
local varname ate
local group1 tg
local group2 io5

sort `group1' `group2'
gen x = _n
replace x = _n + 2 if _n >= 6 


separate ate, by(io5)
separate yu, by(io5)
separate yl, by(io5)

twoway (scatter ate1 x , msymbol(S) msize(medium) mcolor(black)) ///
       (rcap yu1 yl1 x, lcolor(black))  ///
       (scatter ate2 x , msymbol(Oh) msize(large) mcolor(black)) ///
       (rcap yu2 yl2 x, lcolor(black) )  ///
       (scatter ate3 x , msymbol(T) msize(medium) mcolor(black)) ///
       (rcap yu3 yl3 x, lcolor(black) )  ///
       (scatter ate4 x , msymbol(D) msize(medium) mcolor(black)) ///
       (rcap yu4 yl4 x, lcolor(black) )  ///
       (scatter ate5 x , msymbol(X) msize(large) mcolor(black)) ///
       (rcap yu5 yl5 x, lcolor(black) ), scheme(lean1)  ///
	   xlabel(none) xtitle(" ", size(3)) b2("Treatment groups compared to control group") ///
	   ytitle(Average treatment effect, size(3)) yscale(r(-.6(.5)1)) ///
	   text(-1.09 2.5 "Positive", place(e) size(2.5)) ///
	   text(-1.09 9.5 "Negative", place(e) size(2.5)) ///
	   legend(order(1 "UN" 3 "IMF" 5 "WTO" 7 "EU" 9 "NAFTA") position(1) row(1) ring(0)) ///
	   name(fig6, replace) graphregion(color(white)) ylab(, labsize(2.5) nogrid) ///
	   yline(0, lcolor(black) lpattern(dash))
		   
	   *Adjust x-title manually

saveold allIOs-fig6.dta, replace

exit

